**Project: Strategic Discrimination**
**by Regina Bateson**
**Last modified: 21 June 2020**

//This do-file provides the output for the Study 2 results//

//First, the do-file cleans and re-organizes the dataset.//
//Then, the "Analysis 1" section provides the main results in the manuscript.//
//Last, the "Analysis 2" section provides supplemental analysis cited in the manuscript and the appendix.//

**GET THE DATASET**

//Download and save the file Study2.dta //
//It is part of this replication package // 

use "/Users/gina/Dropbox (Personal)/Strategic Discrimination resubmit/Perspectives Final Submission/Data and Replication Files/Study2.dta"

//Of course your version of the dataset is saved differently. Go open it.//

**CLEAN THE DATA AND SET UP VARIABLES**

**1. Create comparison groups**
//This is necessary in order to be able to compare each treatment group with the control group//

gen whitecompare=.
replace whitecompare=1 if treatment=="MediaAnalysis-WhiteVoters"
replace whitecompare=0 if treatment=="ControlConclusion"

gen stratcompare=.
replace stratcompare=1 if treatment=="StrategicThinkingTreatment"
replace stratcompare=0 if treatment=="ControlConclusion"

gen malecompare=.
replace malecompare=1 if treatment=="MediaAnalysis-MaleVoters"
replace malecompare=0 if treatment=="ControlConclusion"

**2. Create DVs **

//Start with WOMEN candidates//

replace warren=0 if warren==.
replace harris=0 if harris==.
replace buttigieg=0 if buttigieg==.
replace booker=0 if booker==.
replace klobuchar=0 if klobuchar==.
replace biden=0 if biden==.
replace sanders=0 if sanders==.
replace orourke=0 if orourke==.

//Top choice is a woman (binary)//

gen bestwoman1=0
replace bestwoman1=1 if warren==1
replace bestwoman1=1 if harris==1
replace bestwoman1=1 if klobuchar==1

//Total number of women in the top 3//
gen bestwarrentop3=0
replace bestwarrentop3=1 if warren>0
gen bestharristop3=0
replace bestharristop3=1 if harris>0
gen bestklobuchartop3=0
replace bestklobuchartop3=1 if klobuchar>0
gen bestwomantotal=bestwarrentop3+bestharristop3+bestklobuchartop3

//Are any women in the top 3 (binary)?//
gen bestwomanbinary=0
replace bestwomanbinary=1 if klobuchar>0
replace bestwomanbinary=1 if warren>0
replace bestwomanbinary=1 if harris>0

//Now turn to BLACK candidates//

replace booker=0 if booker==.

//Black candidate is top choice (binary)//
gen bestblack1=0
replace bestblack1=1 if harris==1
replace bestblack1=1 if booker==1

//Total number of black candidates in top 3//
gen bestbookertop3=0
replace bestbookertop3=1 if booker>0
gen bestblacktotal=bestbookertop3+bestharristop3

//Are there any black candidates in the top 3?//
gen bestblackbinary=0
replace bestblackbinary=1 if harris>0
replace bestblackbinary=1 if booker>0

//Now create CANDIDATE-SPECIFIC DVs//

//Make binary variables recording whether each candidate is in the #1 position//
gen biden1=0
replace biden1=1 if biden==1

gen sanders1=0
replace sanders1=1 if sanders==1

gen warren1=0
replace warren1=1 if warren==1

gen harris1=0
replace harris1=1 if harris==1

gen booker1=0
replace booker1=1 if booker==1

gen klobuchar1=0
replace klobuchar1=1 if klobuchar==1

gen buttigieg1=0
replace buttigieg1=1 if buttigieg==1

gen orourke1=0
replace orourke1=1 if orourke==1

//Create binary variables recording whether each candidate is in the top3//

rename bestharristop3 harristop3
rename bestwarrentop3 warrentop3
rename bestbookertop3 bookertop3
rename bestklobuchartop3 klobuchartop3

gen bidentop3=0
replace bidentop3=1 if biden>0

gen sanderstop3=0
replace sanderstop3=1 if sanders>0

gen buttigiegtop3=0
replace buttigiegtop3=1 if buttigieg>0

gen orourketop3=0
replace orourketop3=1 if orourke>0

**Generate dummy variables to indicate which subjects in the "strategic thinking" treatment**
**had high estimates of racism & sexism, and which had low estimates**

gen woman35=.
replace woman35=0 if stratcomp==1
replace woman35=1 if stratcomp==1 & notvotewoman>34
**The variable woman35 is coded 1 if the subjects said that 35% or more of swing-state voters would not vote**
**for a woman for president. I chose the number 35 because it is the median (the mean is slightly higher).**

gen woman15=. 
replace woman15=0 if stratcomp==1
replace woman15=1 if stratcomp==1 & notvotewoman>15

gen woman25=. 
replace woman25=0 if stratcomp==1
replace woman25=1 if stratcomp==1 & notvotewoman>24

**Same logic, for black candidates**

gen black35=.
replace black35=0 if stratcomp==1
replace black35=1 if notvoteblack>34 & stratcomp==1

gen black15=. 
replace black15=0 if stratcomp==1
replace black15=1 if stratcomp==1 & notvoteblack>15

gen black25=. 
replace black25=0 if stratcomp==1
replace black25=1 if stratcomp==1 & notvoteblack>24

**Code Subject Demographics**

gen male=0 if gender!="Male"
replace male=1 if gender=="Male"

gen female=0 if gender!="Female"
replace female=1 if gender=="Female"

gen white=0 
replace white=1 if race=="White / Caucasian" 

gen black=0
replace black=1 if race=="Black or African American"

gen api=0
replace api=1 if race=="Asian / Pacific Islander"

gen hispanic=0
replace hispanic=1 if race=="Hispanic or Latino"

gen other=0
replace other=1 if hispanic==0 & api==0 & black==0 & white==0

gen agegroup=1 if age=="18 - 24 years old"
replace agegroup=2 if age=="25 - 34 years old"
replace agegroup=3 if age=="35 - 44 years old"
replace agegroup=4 if age=="45 - 54 years old"
replace agegroup=5 if age=="55 - 64 years old"
replace agegroup=6 if age=="65 - 74 years old"
replace agegroup=7 if age=="75 years or older"

********************************************************************************
*********ANALYSIS 1*************************************************************
********************************************************************************

//for TABLE 2.2//
**Male Voters Treatment**
ttest bestwomanbin, by(malecomp) welch
ttest bestwoman1, by(malecomp) welch
ttest bestwomantot, by(malecomp) welch

//for Table 2.3//
**White Voters Treatment**
ttest bestblackbin, by(whitecomp) welch
ttest bestblack1, by(whitecomp) welch
ttest bestblacktot, by(whitecomp) welch

//for Table 2.4//
**Estimate Others' Biases Treatment**
ttest bestwomanbin, by(stratcomp) welch
ttest bestwomantot, by(stratcomp) welch
ttest bestwoman1, by(stratcomp) welch
ttest bestblackbin, by(stratcomp) welch
ttest bestblacktot, by(stratcomp) welch
ttest bestblack1, by(stratcomp) welch

********************************************************************************
*********ANALYSIS 2*************************************************************
********************************************************************************

//APPENDIX TABLE 1.33//
//Estimates of others' racism/sexism, by subject demographics//

**Who over-estimates sexism most?**
sum notvotewoman if male==1
sum notvotewoman if female==1

sum notvotewoman if white==1
sum notvotewoman if black==1
sum notvotewoman if hispanic==1 
sum notvotewoman if api==1

sum notvotewoman if agegr<3
sum notvotewoman if agegr>2 & agegr<5
sum notvotewoman if agegr>4

**Who over-estimates racism most?**
sum notvoteblack if male==1
sum notvoteblack if female==1

sum notvoteblack if white==1
sum notvoteblack if black==1
sum notvoteblack if hispanic==1 
sum notvoteblack if api==1

sum notvoteblack if agegr<3
sum notvoteblack if agegr>2 & agegr<5
sum notvoteblack if agegr>4

//APPENDIX TABLE 1.34//
//Subject demographics//

tab agegr
tab female
tab male
tab other
tab white
tab black
tab hispanic
tab api

//After Table 2.4, the manuscript discusses heterogenous treatment effects//
//across subjects with low and high estimates of others' sexism and racism.//

//That discussion is based on the following analysis.//

sum notvotewoman if stratcomp==1
sum notvoteblack if stratcomp==1

sum bestwomanbin if woman15==0
sum bestwomanbin if woman15==1

sum bestwomanbin if woman25==0
sum bestwomanbin if woman25==1

sum bestwomanbin if woman35==0
sum bestwomanbin if woman35==1

sum bestblackbin if black15==0
sum bestblackbin if black15==1

sum bestblackbin if black25==0
sum bestblackbin if black25==1

sum bestblackbin if black35==0
sum bestblackbin if black35==1

//That's the end of this do-file.//
//For candidate-specific results used to make Figures 2.1 and 2.2, see the do-file Study2_Figure.do //

clear 
